package com.bgs.eat.area.controller;

import com.bgs.eat.area.entity.dto.getAllCityAreaDto;
import com.bgs.eat.area.service.AreaService;
import com.bgs.eat.config.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName AreaController
 * @Description TODO
 * @Author lzy
 * @Date 2022/10/11 13:56
 **/
@RestController
@RequestMapping("/area")
@CrossOrigin
public class AreaController {

    @Autowired
    AreaService areaService;

    /**
    * @Description 获取省市县的数据（前台展示）
    * @Author lzy
    * @Date 2022/10/11 13:59
    * @Return com.bgs.eat.config.CommonResult

    */
    @GetMapping("/getAreaList")
    public CommonResult getAreaList(){
        return areaService.getAreaList();
    }

    /* *
     * @Author: beisheng
     * @Descriprion: 获取全部省的信息
     * @Date: 2022/10/12 19:00
     * @Return: com.bgs.eat.config.CommonResult
     * @Param: null
     */

    @GetMapping("/getAllProvinces")
    public CommonResult getAllProvinces(){
        return areaService.getAllProvinces();
    }

    /* *
     * @Author: beisheng
     * @Descriprion: 根据选择的省的ID查询当前省下的所有市
     * @Date: 2022/10/13 10:27
     * @Return: com.bgs.eat.config.CommonResult
     * @Param: [allCityAreaDto]
     */

    @PostMapping("/getAllCityArea")
    public CommonResult getAllCityArea(@RequestBody getAllCityAreaDto allCityAreaDto){
        return areaService.getAllCityArea(allCityAreaDto);
    }

    /* *
     * @Author: beisheng
     * @Descriprion: 根据市ID获取当前市下的所有县/区
     * @Date: 2022/10/13 11:31
     * @Return: com.bgs.eat.config.CommonResult
     * @Param: [id]
     */

    @GetMapping("/getAllArea")
    public CommonResult getAllArea(Integer id){
        return areaService.getAllArea(id);
    }

    /**
    * @Author G胖
    * @Description 查询所有地区信息
    * @Date 2022-10-25 下午 07:52
    * @Return

    */
    @GetMapping("/getAllAreaDetails")
    public CommonResult getAllAreaDetails(){
        return CommonResult.ok(areaService.getAllAreaDetails());
    }

    /**
    * @Author gpd
    * @Description 查询用户的详细地址
    * @Date 2022-11-01 下午 03:03
    * @Return com.bgs.eat.config.CommonResult

    */
    @GetMapping("/getUserAreaAddress")
    public CommonResult getUserAreaAddress(Integer id){
        return CommonResult.ok(areaService.getUserAreaAddress(id));
    }
}
